<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>
    <link rel='stylesheet' href='/lib/bootstrap/dist/css/bootstrap.min.css' />
    <link rel='stylesheet' href='/stylesheets/font-awesome.min.css' />
    <link rel='stylesheet' href='/stylesheets/ionicons.min.css' />
    <link rel='stylesheet' href='/lib/admin-lte/dist/css/AdminLTE.min.css' />
    <link rel='stylesheet' href='/lib/admin-lte/dist/css/skins/skin-blue.min.css' />
    <link rel='stylesheet' href='/stylesheets/style.css' />
  </head>
  <body class="hold-transition skin-blue sidebar-mini">
  <div class="wrapper">

    <% include header.ejs %>

    <% include menu.ejs %>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
      <!-- Main content -->
      <section class="content">

        <!-- Your Page Content Here -->
        <div class="box">
          <div class="box-header with-border">
            <h3 class="box-title">
              <%= bannerStr %>轮播图列表
              <button class="btn btn-sm btn-success" onclick="toAddBanner(<%= bannerType %>)"><span class="glyphicon glyphicon-plus"></span> 添加</button>
            </h3>
            <button class="btn btn-sm btn-default pull-right" > 导入数据</button>
            <button class="btn btn-sm btn-info pull-right" > 导出数据</button>
          </div>
          <!-- /.box-header -->
          <div class="box-body">
            <table class="table table-bordered">
              <tr>
                <th style="width: 10px">#</th>
                <th>图片ID</th>
                <th>图片</th>
                <th>链接地址</th>
                <th>操作</th>
              </tr>
             <% for(var i=0; i< result.length; i++){  %>
              <tr>
                <td><%= i+1 %></td>
                <td>
                    <%= result[i].bannerID %>
                </td>
                <td>
                  <img src="<%= result[i].bannerSrc %>" style="width: 60px">
                </td>
                <td>
                    <%= result[i].linkSrc %>
                </td>
                <td>
                  <button class="btn btn-xs btn-warning" onclick="updateBanner(<%- result[i].bannerID %>)">
                    <span class="glyphicon glyphicon-edit"></span>
                    编辑
                  </button>
                  <button class="btn btn-xs btn-danger" onclick = "deleteBanner(<%- result[i].bannerID %>)">
                    <span class="glyphicon glyphicon-trash"></span>
                    删除
                  </button>
                </td>
              </tr>
            <% } %>
            </table>
          </div>
          <!-- /.box-body -->
          <div class="box-footer clearfix">
            <ul class="pagination pagination-sm no-margin pull-right">
              <li><a href="#">&laquo;</a></li>
              <li><a href="#">1</a></li>
              <li><a href="#">2</a></li>
              <li><a href="#">3</a></li>
              <li><a href="#">&raquo;</a></li>
            </ul>
          </div>
        </div>
      </section>
      <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <!-- Main Footer -->
    <% include footer.ejs %>


    <!-- Add the sidebar's background. This div must be placed
         immediately after the control sidebar -->
    <div class="control-sidebar-bg"></div>
  </div>
  <!-- ./wrapper -->
  </body>
  <script src = "/javascripts/jquery.min.js"></script>
  <script src = "/lib/bootstrap/dist/js/bootstrap.min.js"></script>
  <script src = "/javascripts/app.min.js"></script>
  <script>
    // 添加事件
    function toAddBanner(bannerType){
        window.location.href = "/banner/addbanner?bannerType=" + bannerType;
    }
    // 轮播编辑 更新
    function updateBanner (bannerID) {
      window.location.href = "/banner/updateBanner?bannerID=" + bannerID;
    }
    // 删除事件
    function deleteBanner(bannerID) {
    // console.log(bannerID);
    window.location.href = "/banner/deleteBanner?id=" + bannerID + '&type=' + window.location.href.split('bannerType=')[1];
  };
  </script>

</html>
